<template>
    <van-sticky>
    <van-nav-bar title="公告" left-text="返回" left-arrow @click-left="onClickLeft" /></van-sticky>
    <!-- <MyLoading v-if="loadingTag" /> -->
    <div class="box" ref="noticeBox">
        <div class="box-one" @click="noticeDetail(item.id)" v-for="(item, index) in noticeList" :key="index">
            <div class="box-two">
                <h3>{{ item.noticeName }}</h3>
                <span class="text">{{ item.noticeContent }}</span>
                <span class="time">{{ item.effectiveDate }}</span>
            </div>
            <hr>
        </div>
    </div>
    <!-- <div id="bigbox">
    <div id="box" @click="noticeDetial(item.id)" v-for="(item, index) in noticelist" :key="index">
        <h4>{{ item.noticeName }}</h4>
  <van-cell title=item.noticeName value="item.noticeContent" label="item.effectiveDate" />
</div>
</div> -->
</template>
    
<script setup lang='ts'>
import { ref, onUnmounted, onMounted } from 'vue'
import { getNotice } from '../api/api'
import { useRouter } from 'vue-router';
import $bus from "../config/eventBus";
//  刷新
let loadingTag = ref<boolean>(true);
const router = useRouter()
const noticeDetail = (noticeId: any) => {
    // 进行路由跳转
    router.push({ path: "/noticeDetail", query: { params: noticeId } })
};


const noticeList = ref<any>([{}])
onMounted(async () => {
    const data = {}
    const ret = await getNotice(data);
    if (ret.data.code === 0) {
        noticeList.value.push(...ret.data.data.data)
    } else {
        return false
    }

});





//  返回上一页
const onClickLeft = () => history.back();
//登陆页不要tabBar
onMounted(() => {
    $bus.emit("tabBarHide", false);
})
//页面离开记得销毁
onUnmounted(() => {
    $bus.emit("tabBarHide", true);
})
</script>
    
<style scoped lang='scss'>
.box {
    width: 100%;

}

.text {
    white-space: nowrap;
    /*强制span不换行*/
    display: inline-block;
    /*将span当做块级元素对待*/
    width: 260px;
    /*限制宽度*/
    overflow: hidden;
    /*超出宽度部分隐藏*/
    text-overflow: ellipsis;
    /*超出部分以点号代替*/
    line-height: 0.9;
    /*数字与之前的文字对齐*/
}

.time {
    float: right;
}
</style>